-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Deduplicated float tests and unified in floats/mod.rs #148206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Any update @bjorn3 ? |
|
CI is still failing. |
ok let me fix . |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
b802b19 to
abd73fd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| let inf: Float = Float::INFINITY; | ||
| let neg_inf: Float = Float::NEG_INFINITY; | ||
| assert_biteq!((10.0 as Float).log(10.0), 1.0); | ||
| assert_approx_eq!((2.3 as Float).log(3.5), 0.664858, Float::LOG_APPROX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test here for f128 will fail because the precision is much higher, if you look at the original test, the expected value is much more precise than what you have written:
assert_approx_eq!(2.3f128.log(3.5), 0.66485771361478710036766645911922010272, TOL);When testing higher precision floats, you need much more precise expected values or the tests will fail, as they do now. In Miri, this is even more strict.
If you look at the source of f16 constants, they use much more digits after the decimal point than needed:
pub const PI: f16 = 3.14159265358979323846264338327950288_f16;So you should probably do that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay it makes sense . Thanks
|
Thank you for the final cleanup here. Until CI is fixed, |
|
Reminder, once the PR becomes ready for a review, use |
Will finish this as soon as possible . A bit busy these days. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0f27f23 to
507fb72
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
958d860 to
a2ffe8b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
a2ffe8b to
6ac8ff7
Compare
|
@tgross35 is anything more needed on this ? |
|
Thank you for all the work here! Final results LGTM. @bors r+ |
| f16: #[cfg(any(miri, target_has_reliable_f16))], | ||
| f128: #[cfg(any(miri, target_has_reliable_f128))], | ||
| f16: #[cfg(any(miri, target_has_reliable_f16_math))], | ||
| f128: #[cfg(any(miri, target_has_reliable_f128_math))], | ||
| }, | ||
| test<Float> { | ||
| let pi: Float = Float::PI; | ||
| let pi: Float = consts::PI; | ||
| let nan: Float = Float::NAN; | ||
| let inf: Float = Float::INFINITY; | ||
| let neg_inf: Float = Float::NEG_INFINITY; | ||
| assert_biteq!((0.0 as Float).to_degrees(), 0.0); | ||
| assert_approx_eq!((-5.8 as Float).to_degrees(), -332.31552117587745090765431723855668471); | ||
| assert_biteq!(flt(0.0).to_degrees(), 0.0); | ||
| assert_approx_eq!(flt(-5.8).to_degrees(), -332.31552117587745090765431723855668471); | ||
| assert_approx_eq!(pi.to_degrees(), 180.0, Float::PI_TO_DEGREES_APPROX); | ||
| assert!(nan.to_degrees().is_nan()); | ||
| assert_biteq!(inf.to_degrees(), inf); | ||
| assert_biteq!(neg_inf.to_degrees(), neg_inf); | ||
| assert_biteq!((1.0 as Float).to_degrees(), 57.2957795130823208767981548141051703); | ||
| assert_biteq!(flt(1.0).to_degrees(), 57.2957795130823208767981548141051703); | ||
| } | ||
| } | ||
|
|
||
| float_test! { | ||
| name: to_radians, | ||
| attrs: { | ||
| f16: #[cfg(any(miri, target_has_reliable_f16))], | ||
| f128: #[cfg(any(miri, target_has_reliable_f128))], | ||
| f16: #[cfg(any(miri, target_has_reliable_f16_math))], | ||
| f128: #[cfg(any(miri, target_has_reliable_f128_math))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target_has_reliable_* -> target_has_reliable_*_math changes were not required here; to_radians/to_degrees are just math operations and don't need to link libm.
It's not worth blocking this on, but would you be able to send a followup changing them back? Or do the change in this PR if you get to it before it merges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgross35 I just saw this and bors already committed this PR . So I think a followup will be the best option here .
…tgross35 Deduplicated float tests and unified in floats/mod.rs In this PR Float tests are deduplicated and are unified in floats/mod.rs, as discussed in rust-lang#141726. The moved float tests are: -> test_powf -> test_exp -> test_exp2 -> test_ln -> test_log_generic -> test_log2 -> test_log10 -> test_asinh -> test_acosh -> test_atanh -> test_gamma -> test_ln_gamma Closes: rust-lang#141726
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
|
⌛ Testing commit 6ac8ff7 with merge e822724... Workflow: https://github.com/rust-lang/rust/actions/runs/21248296883 |
Deduplicated float tests and unified in floats/mod.rs In this PR Float tests are deduplicated and are unified in floats/mod.rs, as discussed in #141726. The moved float tests are: -> test_powf -> test_exp -> test_exp2 -> test_ln -> test_log_generic -> test_log2 -> test_log10 -> test_asinh -> test_acosh -> test_atanh -> test_gamma -> test_ln_gamma Closes: #141726
|
@bors yield |
|
Auto build cancelled. Cancelled workflows: The next pull request likely to be tested is #151485. |
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
|
Actually I think this PR failed that rollup Not sure, if you disagree start a try job and then r+ again |
|
Commit 6ac8ff7 has been unapproved. |
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
In this PR Float tests are deduplicated and are unified in floats/mod.rs, as discussed in #141726.
The moved float tests are:
-> test_powf
-> test_exp
-> test_exp2
-> test_ln
-> test_log_generic
-> test_log2
-> test_log10
-> test_asinh
-> test_acosh
-> test_atanh
-> test_gamma
-> test_ln_gamma
Closes: #141726
r? tgross35